package com.koron.system.agent.controller;

import com.koron.bean.base.Response;
import com.koron.bean.query.PageQuery;
import com.koron.bean.system.agent.po.AgentRoleUserPo;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.system.agent.service.AgentRoleUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 代理用户关联角色表(AgentRoleUser)表控制层
 *
 * @author zhouj
 * @since 2021-11-23 18:03:34
 */
@Api(tags = "代理用户关联角色表(AgentRoleUser)")
@RestController
@RequestMapping("/agentRoleUser/")
public class AgentRoleUserController {

    @Autowired
    private AgentRoleUserService agentRoleUserService;

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }

    @ApiOperation(value = "新增或修改代理用户关联角色表")
    @PostMapping("insertOrUpdate")
    public Response insertOrUpdate(@RequestBody AgentRoleUserPo agentRoleUser) {
        return Response.ok(agentRoleUserService.insertOrUpdate(agentRoleUser));
    }

    @ApiOperation(value = "新增代理用户关联角色表")
    @PostMapping("insert")
    public Response insert(@RequestBody AgentRoleUserPo agentRoleUser) {
        return Response.ok(agentRoleUserService.insert(agentRoleUser));
    }

    @ApiOperation(value = "批量新增代理用户关联角色表")
    @PostMapping("insertBatch")
    public Response insertBatch(@RequestBody List<AgentRoleUserPo> agentRoleUserList) {
        return Response.ok(agentRoleUserService.insertBatch(agentRoleUserList));
    }

    @ApiOperation(value = "根据id更新代理用户关联角色表")
    @PutMapping("update")
    public Response update(@RequestBody AgentRoleUserPo agentRoleUser) {
        return Response.ok(agentRoleUserService.update(agentRoleUser));
    }

    @ApiOperation(value = "根据id删除代理用户关联角色表")
    @DeleteMapping("deleteById")
    public Response deleteById(String id) {
        return Response.ok(agentRoleUserService.deleteById(id));
    }

    @ApiOperation(value = "根据id查询代理用户关联角色表")
    @GetMapping("queryById")
    public Response<AgentRoleUserPo> queryById(String id) {
        return Response.ok(agentRoleUserService.queryById(id));
    }

    @ApiOperation(value = "不分页查询代理用户关联角色表列表")
    @GetMapping("queryList")
    public Response queryList(AgentRoleUserPo queryVo) {
        return Response.ok(agentRoleUserService.queryList(queryVo));
    }

    @ApiOperation(value = "分页查询代理用户关联角色表列表")
    @GetMapping("queryPageList")
    public Response queryPageList(AgentRoleUserPo queryPo, PageQuery pageQuery) {
        return Response.ok(agentRoleUserService.queryPageList(queryPo, pageQuery));
    }

}
